using JlPay.Sdk.Core;

namespace JlPay.Sdk.Core
{
    /// <summary>
    /// Demo配置工具类
    /// 提供便捷的demo配置创建方法，用于简化demo示例代码
    /// </summary>
    public static class DemoConfig
    {
        // =================== Demo密钥常量 =====================
        
        /// <summary>
        /// Demo SM2公钥
        /// </summary>
        public const string DEMO_SM2_PUBLIC_KEY = @"-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEJJhFmjeMRp9GwShxtWunv6Wny//m
Dg2pcnu0llDQvIYo5O3R+al39NekciZ0BIrT21Y/QJrXgJIoyBr6STml6g==
-----END PUBLIC KEY-----";

        /// <summary>
        /// Demo SM2私钥
        /// </summary>
        public const string DEMO_SM2_PRIVATE_KEY = @"-----BEGIN EC PRIVATE KEY-----
MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgHqOp471SMDsQml2G
2ErpZPLD2X7rbMqa6P1O9Zqlhe+gCgYIKoEcz1UBgi2hRANCAAQkmEWaN4xGn0bB
KHG1a6e/pafL/+YODalye7SWUNC8hijk7dH5qXf016RyJnQEitPbVj9AmteAkijI
GvpJOaXq
-----END EC PRIVATE KEY-----";

        /// <summary>
        /// Demo 嘉联支付平台公钥
        /// </summary>
        public const string DEMO_JLPAY_PUBLIC_KEY = @"-----BEGIN PUBLIC KEY-----
MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////v//////////
//////////8AAAAA//////////8wRAQg/////v////////////////////8AAAAA
//////////wEICjp+p6dn140TVqeS89lCafzl4n1FauPkt28vUFNlA6TBEEEMsSu
LB8ZgRlfmQRGajnJlI/jC7/yZgvhcVpFiTNMdMe8Nzai9PZ3nFm9zuNraSFT0KmH
fMYqR0AC3zLlITnwoAIhAP////7///////////////9yA99rIcYFK1O79Ak51UEj
AgEBA0IABKZ3VWwH0Aw9xvOWXb+xM2gXyApWEAZLFy8UyIigp3ehOTwPJ693njrg
NavTLdzAtFBqXRreivlwBTIFy8iRgn8=
-----END PUBLIC KEY-----";

        // =================== Demo应用配置常量 =====================
        
        /// <summary>
        /// Demo 应用ID
        /// </summary>
        public const string DEMO_APP_ID = "1vzougr30f9vcw";
        
        /// <summary>
        /// 生产环境API地址
        /// </summary>
        public const string PROD_API_URL = "https://openapi.jlpay.com";
        
        /// <summary>
        /// UAT测试环境API地址
        /// </summary>
        public const string UAT_API_URL = "https://openapi-uat.jlpay.com";
        
        /// <summary>
        /// 文件上传UAT测试环境API地址
        /// </summary>
        public const string UAT_UPLOAD_API_URL = "https://upload-uat.jlpay.com";

        // =================== Demo配置创建方法 =====================
        
        /// <summary>
        /// 创建加密配置对象（用于含有敏感字段的场景）
        /// </summary>
        /// <param name="isProd">是否为生产环境，默认false（UAT环境）</param>
        /// <param name="autoEncrypt">是否自动加密，默认true</param>
        /// <param name="autoDecrypt">是否自动解密，默认true</param>
        /// <param name="cryptoAlg">加密算法，默认"SM2WithSM4"</param>
        /// <returns>配置对象</returns>
        public static Config CreateConfigWithCrypto(
            bool isProd = false,
            bool autoEncrypt = true,
            bool autoDecrypt = true,
            string cryptoAlg = "SM2WithSM4"
        )
        {
            var url = isProd ? PROD_API_URL : UAT_API_URL;
            
            return new Config
            {
                AppId = DEMO_APP_ID,
                BaseUrl = url,
                PrivateKey = DEMO_SM2_PRIVATE_KEY,
                JlpayPublicKey = DEMO_JLPAY_PUBLIC_KEY,
                AutoEncrypt = autoEncrypt,
                CryptoAlg = cryptoAlg,
                AutoDecrypt = autoDecrypt,
                Debug = false 
            };
        }
        
        /// <summary>
        /// 创建标准demo配置对象（用于不含有敏感字段的场景）
        /// </summary>
        /// <param name="isProd">是否为生产环境，默认false（UAT环境）</param>
        /// <returns>配置对象</returns>
        public static Config CreateConfig(bool isProd = false)
        {
            var url = isProd ? PROD_API_URL : UAT_API_URL;
            
            return new Config
            {
                AppId = DEMO_APP_ID,
                BaseUrl = url,
                PrivateKey = DEMO_SM2_PRIVATE_KEY,
                JlpayPublicKey = DEMO_JLPAY_PUBLIC_KEY,
                AutoEncrypt = false,
                AutoDecrypt = false,
                Debug = false
            };
        }
        
        /// <summary>
        /// 创建文件上传demo配置对象
        /// </summary>
        /// <param name="isProd">是否为生产环境，默认false（UAT环境）</param>
        /// <returns>配置对象</returns>
        public static Config CreateUploadConfig(bool isProd = false)
        {
            var url = isProd ? PROD_API_URL : UAT_UPLOAD_API_URL;
            
            return new Config
            {
                AppId = DEMO_APP_ID,
                BaseUrl = url,
                PrivateKey = DEMO_SM2_PRIVATE_KEY,
                JlpayPublicKey = DEMO_JLPAY_PUBLIC_KEY,
                AutoEncrypt = false,
                AutoDecrypt = false,
                Debug = false
            };
        }
        
        // =================== Demo工具方法 =====================
        
        /// <summary>
        /// 获取demo应用ID
        /// </summary>
        /// <returns>应用ID</returns>
        public static string GetDemoAppId()
        {
            return DEMO_APP_ID;
        }
    }
} 